import os
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import sys
img_path = '/home/sean/data/UWdevkit/extra/Data/train/n02317335'
# anno_path = '/home/sean/data/UWdevkit/Annotations/train/Video10_00'# i = 0

path = img_path

for file in os.listdir(path):
    if os.path.isfile(os.path.join(path,file)) == True:
        name = file.split('.')
        if name[1] != 'jpg' and name[1] != 'xml':
            name[1] = 'jpg'
        newname = name[0]+'.'+name[1]
        # name[0] = 'Video5_' + name[0]
        # i = i+1
        # name_split = name[0].split('_')
        # if name_split[0] == 'Video10':
        #     newname = name_split[1].zfill(6)+'.'+name[1]
        print(file, newname)
        os.rename(os.path.join(path, file), os.path.join(path,newname))
